package com.sc.nft.entity.vo.secondEquityProp;

import cn.hutool.core.convert.Convert;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.sc.nft.enums.OrderStatusEnum;
import com.sc.nft.enums.PayMethodEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

@Data
public class SecondEquityPropBuyOrderPageVO {


    @ApiModelProperty("订单id")
    private Long orderId;

    @ApiModelProperty("订单编号")
    private String orderNo;

    @ApiModelProperty("权益道具id")
    private Long equityPropsId;

    @ApiModelProperty("商品id")
    private Long secondProductId;

    @ApiModelProperty("权益道具")
    private String firstTitle;

    @ApiModelProperty("手续费")
    private String charge;

    @ApiModelProperty("支付金额")
    private String buyPrice;

    @ApiModelProperty("交易时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private String dealTime;

    @ApiModelProperty("订单状态 CLOSE:关闭 WAIT_PAY:待支付 PAYMENT:已付款")
    private OrderStatusEnum status;

    @ApiModelProperty("买家昵称")
    private String buyUserNickName;

    @ApiModelProperty("卖家昵称")
    private String salesUserNickName;

    @ApiModelProperty("图片")
    private String creationContent;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty("支付时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date payTime;

    @ApiModelProperty("关闭时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date realCloseTime;

    @ApiModelProperty("支付金额")
    private String realAmount;

    @ApiModelProperty("店铺名称")
    private String shopName;


    @ApiModelProperty("支付方式")
    private PayMethodEnum payType;

    @ApiModelProperty("收款方式")
    private PayMethodEnum receiveType;

    private String payIcon;
    private String receiveIcon;

    /**
     * 求购单Id
     */
    private Long wantBuyOrderId;


    public void setCharge(BigDecimal charge) {
        this.charge = charge.setScale(2,BigDecimal.ROUND_DOWN).toPlainString();
    }

    public void setBuyPrice(BigDecimal buyPrice) {
        this.buyPrice = buyPrice.setScale(2,BigDecimal.ROUND_DOWN).toPlainString();
        this.realAmount = buyPrice.subtract(Convert.toBigDecimal(this.charge)).setScale(2,BigDecimal.ROUND_DOWN).toPlainString();
    }
}
